<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');
/* ************************************************** *\
 * @company		: NovaITech							  *	
 * @author		: van.vo@novaitech.com				  * 
 * @copyright	: 2012								  * 
 * ================================================== *
 * @date		: 04/26/2012
 * @project		: Drag & Drop
 * @description	: 
 *		- 
 *
\* ************************************************** */

class Report extends MY_Controller{
    function __construct( ){
        parent::__construct( );  
		$this->load->helper( array( 'form', 'url' ) );
		$this->load->model( 'CodeGenerator_model', '', TRUE );
		$this->load->helper('date');
		$this->load_template();
    }
	
	function index(){
	// echo 1 & 2;
	// die;
		$combobox_cats=array();
		$selected_cat=$this->input->post('db');
		if(empty($selected_cat)) $selected_cat = 'employee';
		$combobox_cats['employee']="Nhân viên";
		$combobox_cats['customer']="Khách hàng";
		$this->data['combobox_cats']=form_dropdown('db', $combobox_cats,$selected_cat);
		$results= array();
		switch($selected_cat){
			case 'employee':
			  $rules                  =         array(array('field_id' => 'Personal_ID','label' => 'Tài khoản','control' => 'Array', 'class' => 'first border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'DOB','label' => 'Ngày sinh','control' => 'time', 'class' => 'border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'Phone_NO','label' => 'Số đt','control' => 'Array', 'class' => 'border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'Street','label' => 'Street','control' => 'Array', 'class' => 'border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'Position','label' => 'Chức vụ','control' => 'Array', 'class' => 'border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'Hired_Dt','label' => 'Ngày kí hợp đồng','control' => 'time', 'class' => 'border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'Term_Dt','label' => 'Ngày hết hợp đồng','control' => 'time', 'class' => 'border-right', 'style' => 'border-right: solid 3px #fff;',));
				$this->data[ 'rules' ]  =   $rules;
			   
				// Make header
				// --------------------------------------------------
				$header = array( );
				foreach( $rules as $item ){
					$header[ ] = $item[ 'label' ];
				}
			   
				$this->data[ 'header' ] =   $header;
				$results                =   $this->CodeGenerator_model->get( 'employee', 'EE_ID,Personal_ID,DOB,Phone_NO,Street,Position,Yrs_of_exp,Education_Level,Create_Dt,Hired_Dt,Term_Dt,Active,Delete' );
				$this->data[ 'master_limited' ]     =   explode(',', 'EE_ID,Personal_ID,DOB,Phone_NO,Street,Position,Yrs_of_exp,Education_Level,Create_Dt,Hired_Dt,Term_Dt,Active,Delete');
				$this->data['table_name'] = 'Danh sách nhân viên';
				break;
			case 'customer':
				 $rules                  =         array(array('field_id' => 'F_Name','label' => 'Tên','control' => 'Array', 'class' => 'first border-right', 'style' => 'border-right: solid 3px #fff;',),array('field_id' => 'L_Name','label' => 'Họ','control' => 'Array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'DOB','label' => 'Ngày sinh','control' => 'array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'Phone_NO','label' => 'Số ĐT','control' => 'Array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'Street','label' => 'Đường','control' => 'Array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'District_City','label' => 'Tp','control' => 'Array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'Membership_Type','label' => 'Loại thành viên','control' => 'Array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'Email_Addr','label' => 'Email','control' => 'Array','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'),array('field_id' => 'Create_Dt','label' => 'Ngày tạo','control' => 'time','class' => 'border-right', 'style' => 'border-right: solid 3px #fff;'));
				$this->data[ 'rules' ]  =   $rules;
			   
				// Make header
				// --------------------------------------------------
				$header = array( );
				foreach( $rules as $item ){
					$header[ ] = $item[ 'label' ];
				}
			   
				$this->data[ 'header' ] =   $header;
				$results                =   $this->CodeGenerator_model->get( 'customer', 'Cust_ID,F_Name,L_Name,DOB,Phone_NO,Street,District_City,Membership_Type,Email_Addr,Create_Dt,Delete' );
				 $this->data[ 'master_limited' ]     =   explode(',', 'Cust_ID,F_Name,L_Name,DOB,Phone_NO,Street,District_City,Membership_Type,Email_Addr,Create_Dt,Delete');
				 $this->data['table_name'] = 'Danh sách khách hàng';
				break;
		}
		$this->data['results'] = $results;
		$this->template->write( 'title', 'Spa - Báo cáo' );
        $this->template->write_view( 'content', 'report.php',$this->data );
        $this->template->render();
    } 
}

/* End of file index.php */
/* Location: ./index.php */